package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.dto.OrdersDto;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    /*
        下单
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Orders orders){
        ordersService.submit(orders);
        return R.success(null);
    }

    /*
        分页查询订单
     */
    @GetMapping("/userPage")
    public R<Page<OrdersDto>> page(Integer page, Integer pageSize){
        Page<OrdersDto> pageInfo = ordersService.page(page,pageSize);

        return R.success(pageInfo);
    }


}
